package com.myd.controller;

import com.myd.model.User;
import com.myd.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.*;


@Path("user")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GET
    @Path("/{name}/{pwd}")
    @ResponseBody
    public User search(@PathParam("name") String username, @PathParam("pwd") String password){
        System.out.println("sssss");
        User user = userService.search(username, password);
        System.out.println(username+password+user);
        if(user != null)
            return user;
        return null;
    }

    @POST
    @Path("/register")
    public boolean register(User user){
//        User user = new User(username,pwd,phone);
        boolean b = userService.insertUser(user);
        System.out.println(b);
        return b;
    }
}
